<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<title>升级套餐</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/mui.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/weui.css">
<script type="text/javascript" src="js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="js/utile.js"></script>
<script type="text/javascript">

var comboList;
$(document).ready(function(){
	var url = getURL() + "/mobile/upCpmboInit";
	  var pram = {};
	  $.ajax({
		  type: 'POST',
		  url: url,
		  data: pram,
		  success: function(data){
			  comboList = data.comboList;
			  $(".first").empty();
				var option = $("<option>").val("-1").text("请选择体检套餐"); 
			  $(".first").append(option); 
			  for (var i = 0;i<data.comboList.length;i++){
				  var item = data.comboList[i];
				  for (var j = 0;j<item.contentList.length;j++){
					  var content = item.contentList[j];
					  if(content.itemType == "1" || content.itemType == "3"){
						  if(data.isSelf == "y" && content.sex != data.sex){
							  continue;
						  }
						  var option = $("<option>").val(content.itemId).text(content.itemName); 
						  $(".first").append(option); 
					  }
				  }
			  }
		  },
		  dataType: "json"
		});

    var url = getURL() + "/user/testMpay";
    $.ajax({
        type: 'POST',
        url: url,
        data: {

        },
        success: function(data){
            $('#payTest').attr("href",data.mweb_url);
        },
        dataType: "json"
    });
});
function back(){
	window.location.href = "before.html";
}

var comboId;

function firstChange(){
	$(".second").empty();
	var option = $("<option>").val("-1").text("请选择体检套餐"); 
  $(".second").append(option); 
  for (var i = 0;i<comboList.length;i++){
	  var item = comboList[i];
	  var selectItem = null;
	  for (var j = 0;j<item.contentList.length;j++){
		  var content = item.contentList[j];
		  if(content.itemId == $(".first").val()){
			  selectItem = content;
			  comboId = item.comboId;
			  break;
		  }
	  }
	  if(selectItem) {
		  for (var j = 0;j<item.contentList.length;j++){
			  var content = item.contentList[j];
			  if(content.itemType == "2" && content.sex == selectItem.sex && selectItem.maritalStatus == content.maritalStatus){
				  var option = $("<option>").val(content.itemId).text(content.itemName); 
				  $(".second").append(option); 
			  }
		  }
	  }
  }
}
function secondChange(){
  for (var i = 0;i<comboList.length;i++){
	  var item = comboList[i];
	  var selectItem1 = null;
	  var selectItem2 = null;
	  for (var j = 0;j<item.contentList.length;j++){
		  var content = item.contentList[j];
		  if(content.itemId == $(".first").val()){
			  selectItem1 = content;
		  }
		  if(content.itemId == $(".second").val()){
			  selectItem2 = content;
		  }
	  }
  }
  if(selectItem2 && selectItem1) {
	  var price = selectItem2.price - selectItem1.price;
	  $(".price").val(price);
  }
}

function commit(){
//	if(!$('.first').val() || $('.first').val() == -1) {
//		alert("请选择升级前套餐");
//		return false;
//	}
//	if(!$('.second').val() || $('.second').val() == -1) {
//		alert("请选择升级后套餐");
//		return false;
//	}
//	var url = getURL() + "/mobile/upSave";
//	  var pram = {};
//	  pram.itemId = $('.second').val();
//	  pram.itemIdOld = $('.first').val();
//	  pram.comboId = comboId;
//
//	  var str = "?";
//	  for ( var p in pram ){
//		  if ( typeof ( pram [ p ]) == " function " ){
//		  } else { // p 为属性名称，obj[p]为对应属性的值
//		  	str +=  p + "=" + pram [ p ] + "&"
//		  }
//	  }
//	  url = url+str;
    var url = getURL() + "/user/testMpay";
    $.ajax({
		  type: 'POST',
		  url: url,
		  data: {

          },
		  success: function(data){

		  },
		  dataType: "json"
	});
//

}

</script>
</head>

<body >
<header id="header" class="mui-bar mui-bar-nav"> <a onclick="history.go(-1)" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color:#fff;"></a>
  <h1 class="mui-title">升级套餐</h1>
</header>
<div class="container loginTop" style="width:80%;">
  <div>
    <h5>升级前套餐</h5>
    <div class="weui_cell weui_cell_select weui_select_after">
      <div class="weui_cell_bd weui_cell_primary">
        <select class="weui_select first" name="select" onChange="firstChange()">
        </select>
      </div>
    </div>
    <h5>升级后套餐</h5>
    <div class="weui_cell weui_cell_select weui_select_after">
      <div class="weui_cell_bd weui_cell_primary">
        <select class="weui_select second" name="select" onChange="secondChange()">
        </select>
      </div>
    </div>
    <div>
      <h5 style="width:100%; line-height:30px; padding-top:10px;"><span style="float:left;">金额：</h5>
      <span style="float:right; width:80%;">
      <input name="" type="text" value="" readonly="true" class="btInp price" style="height:30px; " onmouseover="this.style.borderColor='#30a5ff'" onmouseout="this.style.borderColor='#c9c9c9'">
      </span>
      <div style="clear:both;"></div>
      <p>
        <input type="radio" name="radio" id="pay" value="pay" checked="true">
        <label for="pay">支付宝金额</label>
      </p>
    </div>
  </div>
  <div class="pt30 textCent"><a  href="#" id="payTest" class="weui_btn weui_btn_mini weui_btn_plain_blue " style="width: 30%;padding: 5px;">下一步</a> <a onclick="back()" class="weui_btn weui_btn_mini weui_btn_plain_blue" style="width: 30%;padding: 5px; margin-left:20px;">取消</a> </div>
</div>
</div>
</body>
</html>